package com.shen.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Author:shen
 * CreateDate:2020/6/7.
 * Function:
 */
public class RandomNumber {
    /**
     * 生成不重复的随机
     */
    public  List<Integer> randomNumber(int max,int min,int size){
        List<Integer> list=new ArrayList<>();
        for (int i = 0; i < size; i++) {
            int num =(int) (Math.random() * ((max - min) + min));
            if(list.contains(num)){
              i--;
            }else{
                list.add(num);
            }
        }
        return list;
    }

   /* public static void main(String[] args) {
        List<Integer> list = randomNumber(33, 1, 6);
        list.forEach(System.out::println);

    }*/
}
